package net.huang.libManager.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import java.util.ArrayList;
import java.util.List;

import net.huang.libManager.domain.Manager;
import net.huang.libManager.utils.JDBCUtils;

public class ManagerDao {
    
    // 查询所有管理员的账号和密码
    public List<Manager> getManagersIdAndPwd() {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        List<Manager> list = new ArrayList<Manager>();
        try {
            conn = JDBCUtils.getConnection();
            stmt = conn.createStatement();
            String sql = "select * from manager";
            rs = stmt.executeQuery(sql);
            while (rs.next()) {
                Manager manager = new Manager();
                manager.setMid(rs.getString("mid"));
                manager.setMpwd(rs.getString("mpassword"));
                list.add(manager);
            }
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
}
